<template>
  <div class="cursor-pointer" @click="downloadFile">
    <div class="flex items-center">
      <IconifyIconOffline class="mr-2" :icon="Doc" />
      <div>{{ name }}</div>
    </div>
    <hr class="m-1 text-gray-200" />
    <div class="text-center text-gray-400 text-[10px]">点击下载</div>
  </div>
</template>

<script setup lang="ts">
import Doc from '@iconify-icons/ep/document'

const props = defineProps<{
  url: string
  name: string
}>()
const downloadFile = () => {
  const a = document.createElement('a')
  a.href = props.url
  a.download = props.name
  a.click()
  a.remove()
}
</script>

<style scoped></style>
